const Mock = require('mockjs')

const List = [
        {
            "id": 100,
            "label": "测试集团",
            "children": [
                {
                    "id": 101,
                    "label": "山东总公司",
                    "children": [
                        {
                            "id": 103,
                            "label": "研发部门"
                        },
                        {
                            "id": 104,
                            "label": "市场部门"
                        },
                        {
                            "id": 105,
                            "label": "测试部门"
                        },
                        {
                            "id": 106,
                            "label": "财务部门"
                        },
                        {
                            "id": 107,
                            "label": "运维部门"
                        }
                    ]
                },
                {
                    "id": 102,
                    "label": "山东分公司",
                    "children": [
                        {
                            "id": 108,
                            "label": "市场部门"
                        },
                        {
                            "id": 109,
                            "label": "财务部门"
                        }
                    ]
                }
            ]
        }
    ]
module.exports = [
    {
        url: '/dept/tree',
        type: 'get',
        response: config => {
            return {
                code: 20000,
                data:List
            }
        }
    },

    {
        url: '/dept/detail',
        type: 'get',
        response: config => {
            const { id } = config.query
            for (const article of List) {
                if (article.id === +id) {
                    return {
                        code: 20000,
                        data: article
                    }
                }
            }
        }
    },


    {
        url: '/dept/create',
        type: 'post',
        response: _ => {
            return {
                code: 20000,
                data: 'success'
            }
        }
    },

    {
        url: '/dept/update',
        type: 'post',
        response: _ => {
            return {
                code: 20000,
                data: 'success'
            }
        }
    }
]

